package com.pcbly.web.components.utils.template.service;

import com.pcbly.web.bean.user.*;
import com.pcbly.web.components.utils.template.AbstractModel;
import com.pcbly.web.components.utils.template.ModelPrint;

@SuppressWarnings("unchecked")
public class ModelCommonService extends ModelPrint {

	public void execute(Class clz) {
		if (print) {
			serviceXml(clz);
		} else {
			service(clz);
			serviceXml(clz);
			serviceImp(clz);
		}
	}

	private void service(Class clz) {
		AbstractModel model = new ModelService(clz);
		model.setTableName(tableName);
		model.execute();
	}

	private void serviceXml(Class clz) {
		AbstractModel model = new ModelServiceXml(clz);
		model.setPrint(print);
		model.setTableName(tableName);
		model.execute();
	}

	private void serviceImp(Class clz) {
		AbstractModel model = new ModelServiceImp(clz);
		model.setTableName(tableName);
		model.execute();
	}
 

	private String tableName; 

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public static void main(String[] args) {
		ModelCommonService model = new ModelCommonService();
		model.setTableName("sys_user_school");
		model.setPrint(false);
		model.execute(UserSchoolBean.class);
	}
}
